<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>OA模拟与实现</title>
    <link rel="stylesheet" th:href="@{/bootstrap/bootstrap-3.3.7-dist/css/bootstrap.min.css}"></link>
    <link rel="stylesheet" th:href="@{/css/authoruty.css}"></link>
    <link rel="stylesheet" th:href="@{/css/file.css}"></link>
    <script th:src="@{/js/jquery-3.2.1.min.js}"></script>
<script>
    $(function(){
        $("#sname").focus(function(){
            $("#namemsg").text("");
        });
        $("#identity").focus(function(){
            $("#identitymsg").text("");
        });
        $("#saddr").focus(function(){
            $("#saddrmsg").css("color","red").text("");
        })
        $("#sclass").focus(function(){
            $("#sclassmsg").css("color","red").text("");
        })
        $("#addstu").submit(function(){
            var sname = $("#sname").val();
            var identity = $("#identity").val();
            var saddr = $("#saddr").val()
            var sclass = $("#sclass").val();
            if(sname.length<2||sname==''){
                $("#namemsg").css("color","red").text("请输入正确姓名");
                return false;
            }
            var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
            if(!reg.test(identity)){
                $("#identitymsg").css("color","red").text("请输入正确的身份证")
                return false;
            }
            if(saddr==''){
                $("#saddrmsg").css("color","red").text("请输入地址");
                return false;
            }
            if(sclass==''){
                $("#sclassmsg").css("color","red").text("请输入班级");
                return false;
            }
        })
    })
</script>
</head>
<body>
    <div class="container-fluid">
        <ol class="breadcrumb nav-top">
            <li><a th:href="@{~/router/index.html}" target="main">首页</a></li>
            <li class="active">添加学生</li>
        </ol>
        <div class="panel panel-info">
            <div class="panel-heading">学生详情</div>
            <div class="panel-body">
                <form action="/student/addStudent" id="addstu" method="post" class="form-inline align-self-center">
                    <div>
                        <label for="sname">姓名：</label>
                        <input name="sname" id="sname"/>
                        <span id="namemsg"></span>
                    </div>
                    <div>
                        <label for="identity">身份证：</label>
                        <input name="identity" id="identity"/>
                        <span id="identitymsg"></span>
                    </div>
                    <div>
                        <label for="domain">院部：</label>
                        <select name="doid" id="domain">
                            <option readonly>--请选择--</option>
                            <option th:each="domain : ${domainList}" th:value="${domain.id}" th:text="${domain.domainname}"></option>
                        </select>
                    </div>
                    <div>
                        <label for="depart">专业：</label>
                        <select name="deid" id="depart">
                            <option readonly="">--请选择--</option>
                            <option  th:value="${depart.id}" th:each="depart : ${departList}" th:text="${depart.major}"></option>
                        </select>
                    </div>
                    <div>
                        <label for="people">辅导员：</label>
                        <select name="pid" id="people">
                            <option readonly="">--请选择--</option>
                            <option th:value="${fdy.oid}" th:each="fdy : ${fdyList}" th:text="${fdy.oname}"></option>
                        </select>
                    </div>
                    <div>
                        <label for="saddr">家庭地址：</label>
                        <input name="saddr" id="saddr"/>
                        <span id="saddrmsg"></span>
                    </div>
                    <div>
                        <label for="sclass">班级：</label>
                        <input name="sclass" id="sclass"/>
                        <span id="sclassmsg"></span>
                    </div>
                    <input class="btn btn-info" type="submit"/>
                </form>
            </div>
            
        </div>
        
    </div>
</body>
<script>

</script>
</html>